<template>
<div class="layout">
	<Row type="flex">
		<Col :span="24">
			<Breadcrumb>
				<BreadcrumbItem to="/" @click.native="changeMenu"><Icon type="home"></Icon> 首页</BreadcrumbItem>
				<BreadcrumbItem>{{title}}</BreadcrumbItem>
			</Breadcrumb>
			<div class="cleaner10"></div>
		</Col>

		<Col :span="12">
			<Form :model="vForm">
				<FormItem label="网站名称">
					<Input v-model="vForm.site_name" placeholder="请输入名称..."></Input>
				</FormItem>
				<FormItem label="网站简称">
					<Input v-model="vForm.site_shortname" placeholder="请输入网站简称..."></Input>
				</FormItem>
				<FormItem label="网站关键字">
					<Input v-model="vForm.site_keywords" placeholder="请输入关键字..."></Input>
				</FormItem>
				<FormItem label="网站前端地址">
					<Input v-model="vForm.frontend_url" placeholder="http://..."></Input>
				</FormItem>
				<FormItem label="网站后端地址">
					<Input v-model="vForm.site_url" placeholder="http://..."></Input>
				</FormItem>
				<FormItem label="网站描述">
					<Input type="textarea" :rows="4" v-model="vForm.site_description" placeholder="请输入描述..."></Input>
				</FormItem>
			</Form>
		</Col>
		<Col :span="11" :offset="1">
			<Form :model="vForm">
				<FormItem label="ICP备案号">
					<Input v-model="vForm.icp_no" placeholder="请输入备案号..."></Input>
				</FormItem>
				<FormItem label="用户密码尝试次数">
					<Input v-model="vForm.user_login_incorrect_times" placeholder="请输入数字..."></Input>
				</FormItem>
				<FormItem label="404热线">
					<Input v-model="vForm.hotline_400" placeholder="请输入400电话..."></Input>
				</FormItem>
				<FormItem label="公司地址">
					<Input v-model="vForm.company_address" placeholder="请输入公司地址..."></Input>
				</FormItem>
				<FormItem label="公司邮箱">
					<Input v-model="vForm.company_email" placeholder="请输入公司邮箱..."></Input>
				</FormItem>
				<FormItem label="企业口号">
					<Input v-model="vForm.enterprise_slogan" placeholder="请输入企业口号..."></Input>
				</FormItem>
				<FormItem label="客户QQ">
					<Input v-model="vForm.hotqq" placeholder="请输入客户QQ..."></Input>
				</FormItem>
			</Form>
		</Col>
		<Col :span="5" :offset="1">
		</Col>
		<Col :span="24">
			<Divider dashed />
			<Button type="success" @click="onSubmit">保存</Button>
		</Col>
	</Row>
	<!-- <Modal v-model="showDetail" title="详情" cancel-text="">
		<div v-html="currentContent"></div>
    </Modal> -->
</div>
</template>
<script>


// 引入子组件
import {mapState,mapGetters} from 'vuex'
import { FormItem,Form, Modal, Divider,Row, Col, Button, Breadcrumb, BreadcrumbItem, Icon, Input } from 'iview';
import { isNullOrUndefined } from 'util';
export default { 
	name:'setting-system-index',
	components: {FormItem,Form,  Modal, Divider,Row, Col, Button, Breadcrumb, BreadcrumbItem, Icon, Input},
	data () {
		return {
			title:'系统设置',
			vForm:{
				icp_no:'',
				site_name:'',
				site_keywords:'',
				site_url:'',
				frontend_url:'',
				site_description:'',
				user_login_incorrect_times:3,
				hotqq:'',
				enterprise_slogan:'',
				company_email:'',
				company_address:'',
				hotline_400:'',
				site_shortname:'',
			},
			system:{}
		}
	},
	methods:{
		init:function(){
			let self=this
			self.$Spin.show()
			self.$http.get("/v1/systems",{params: { 'token': self.token }})
			.then(function(response){
				if(200==response.data.status && 0==response.data.code)
				{
					self.vForm=response.data.data
					console.log(response.data)
				}
				self.$Spin.hide()
			}).catch(function(error){
				self.$Spin.hide()
				self.$Message.error(error.message)
			})
		},
		onSubmit:function(){
			let self=this
			self.$Spin.show()
			self.$http.post("/v1/systems?_method=put&token="+self.token,{data:JSON.stringify(self.vForm)})
			.then(function(response){
				if(200==response.data.status && 0==response.data.code)
				{
					self.$Message.info('保存成功');
				}
				self.$Spin.hide()
			}).catch(function(error){
				self.$Spin.hide()
				self.$Message.error(error.message)
			})
		}
	},
	created:function(){
	},
	mounted () {
		this.init()
    	this.setTitle(this.title)
	},
	activated:function(){
		// this.init()
	},
	computed:{
		...mapGetters(['token']),
	},
	watch:{
		realname(curVal,oldVal){
			if(''==curVal){this.uidKey=null}
		}
	}
}



</script>
<style lang="less" scoped>
</style>